package DesignPatern.A10_责任链模式.QSB.A03_通用责任链模式;

/**
 * @Author: Du
 * @Date: 2021/7/30 10:23
 */
public abstract class Handler
{
    private Handler nextHandler;
    
    public final Response handleMessage(Request request)
    {
        Response response = null;
        if (this.getHandlerLevel().equals(request.getRequestLevel()))
        {
            response = this.echo(request);
        } else
        {
            //没有适当的处理者的处理逻辑
        }
        return response;
    }
    
    public void setNext(Handler handler)
    {
        this.nextHandler = handler;
    }
    
    public abstract Level getHandlerLevel();
    
    protected abstract Response echo(Request request);
}
